home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 5 / CU Amiga Magazine's Super CD-ROM 05 (1996)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1996-12].iso / cucd / programming / amos / amospack_8 / button-generator.amos / button-generator.amosSourceCode
Encoding:
AMOS Source Code  |  1992-03-06  |  3.8 KB  |  90 lines

  1. '  ********************* 
  2. '  *                   * 
  3. '  *      Button       *   
  4. '  *     Generator     * 
  5. '  *                   *   
  6. '  *        by         *   
  7. '  *                   * 
  8. '  *   Karl Fletcher   * 
  9. '  *                   * 
  10. '  *   ï¿½ K-Soft 1995   * 
  11. '  *                   ***********************************************   
  12. '  *                                                                 *   
  13. '  *  Use the left mouse button to indicate the top left corner and  * 
  14. '  *  the right mouse button to indicate the bottom right corner     * 
  15. '  *  and a button will be drawn.                                    * 
  16. '  *                                                                 *     
  17. '  *  If you want to save the screen as an IFF for use in 'D Paint'  * 
  18. '  *  (or similar) at any time then press the F10 key and a          * 
  19. '  *  requester will appear for you to enter a file name.            *               *                                                    *    
  20. '  *                                                                 *   
  21. '  *  It's a simple routine designed to save you the hassle of       *   
  22. '  *  drawing buttons for use in util programs etc. .. if you        *     
  23. '  *  happen to want to draw them !                                  *       
  24. '  *                                                                 *   
  25. '  *******************************************************************   
  26.  
  27. Hide : Change Mouse 2
  28. Screen Open 0,640,256,16,Hires : Curs Off : Flash Off : Cls 0 : Paper 3 : Pen 0
  29. Limit Mouse 128,71 To 448,296 : Wait Vbl : Show 
  30. Global X1,X2,Y1,Y2
  31. ' ** Grey palette ** 
  32. Palette $0,$DDD,$BBB,$999,$777,$555,$333,$111,$FFF,$EEE,$CCC,$AAA,$888,$666,$444,$222
  33. ' ** Blue Palette ** 
  34. 'Palette $0,$DDF,$BBF,$99F,$77F,$55F,$33F,$11F,$FFF,$EEF,$CCF,$AAF,$88F,$66F,$44F,$22F 
  35. X1=560 : X2=630 : Y1=4 : Y2=27 : _DRAW : BUTTON
  36.  
  37. Procedure BUTTON
  38.    Do 
  39.       Clear Key 
  40.       Do 
  41.          X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  42.          Paper 3 : Pen 0 : Screen 0 : Locate 71,1
  43.          Print "X=";X;" " : Locate 71,2 : Print "Y=";Y;" "
  44.          If Mouse Key=1 : Goto LEFT
  45.          Else If Mouse Key=0 and Key State(89)=True : Goto _SAVE
  46.          End If 
  47.       Loop 
  48.       
  49.       LEFT:
  50.       X1=X Screen(X Mouse)
  51.       Y1=Y Screen(Y Mouse)
  52.       Plot X1,Y1,9
  53.       Do 
  54.          X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
  55.          Paper 3 : Pen 0 : Screen 0 : Locate 71,1
  56.          Print "X=";X;" " : Locate 71,2 : Print "Y=";Y;" "
  57.          If Mouse Key=2 Then Goto RIGHT
  58.       Loop 
  59.       
  60.       RIGHT:
  61.       X2=X Screen(X Mouse)
  62.       Y2=Y Screen(Y Mouse)
  63.       Plot X2,Y2,9 : Wait 15
  64.       If X1>X2 or Y1>Y2 : Ink 8,0 : Text 10,10,"I can't draw it that way ... please try again !" : Wait 100 : Cls 0,0,0 To 400,12 : Plot X1,Y1,0 : Plot X2,Y2,0
  65.       Else If X2-X1<7 or Y2-Y1<7 : Ink 8,0 : Text 10,10,"It's too small to draw ... have another go !" : Wait 100 : Cls 0,0,0 To 400,12 : Plot X1,Y1,0 : Plot X2,Y2,0
  66.       Else If X1<X2 or Y1<Y2 : _DRAW
  67.       End If 
  68.       
  69.       _SAVE:
  70.       Dir$="DF0:"
  71.       If Key State(89)=True
  72.          F$=Fsel$("*.iff","","Choose an IFF file to Save to")
  73.          If F$="" : Edit 
  74.          Else Paper 0 : Pen 8 : Locate 0,0 : Print "Saving file > ";F$
  75.             Save Iff F$
  76.             Wait 100 : Cls 0,0,0 To 400,12 : Edit 
  77.          End If 
  78.       End If 
  79.    Loop 
  80.    
  81. End Proc
  82. Procedure _DRAW
  83.    Ink 1 : Draw X1,Y1 To X2,Y1 : Draw X1+1,Y1+1 To X2-1,Y1+1 : Draw X1+2,Y1+2 To X2-2,Y1+2
  84.    Ink 2 : Draw X1,Y1+1 To X1,Y2 : Draw X1+1,Y1+2 To X1+1,Y2-1 : Draw X1+2,Y1+3 To X1+2,Y2-2
  85.    Ink 4 : Draw X2,Y1+1 To X2,Y2 : Draw X2-1,Y1+2 To X2-1,Y2-1 : Draw X2-2,Y1+3 To X2-2,Y2-2
  86.    Ink 5 : Draw X1+1,Y2 To X2-1,Y2 : Draw X1+2,Y2-1 To X2-2,Y2-1 : Draw X1+3,Y2-2 To X2-3,Y2-2
  87.    Ink 3 : Bar X1+3,Y1+3 To X2-3,Y2-3
  88.    Ink 8 : Plot X1+3,Y1+3 : Plot X1+3,Y1+4 : Plot X1+4,Y1+3
  89.    Ink 0 : Box X1-1,Y1-1 To X2+1,Y2+1
  90. End Proc